using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter22
{
	/// <summary>
	/// Example02: Freezing Water
	/// A certain refrigerator has a COP of 5.00. When the 
	/// refrigerator is running, its power input is 500 W.
	/// A sample of water of mass 500 g and temperature 20.0 C
	/// is placed in the freezer compartment. How long does
	/// it take to freeze the water to ice at 0 C?
	/// Assume that all other parts of the refrigerator stay at
	/// the same temperature and there is no leakage of energy
	/// from the exterior, so that the operation of the refrigerator
	/// results only in energy being extracted from the water.
	/// \Delta t = 83.3 s
	/// </summary>
	public class Example02
	{
		public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m = new L.Mass();
			m.kg = 0.5;
			L.Temperature t = new L.Temperature();
			t.C = 20.0;
			L.SpecificHeat c = new L.SpecificHeat();
			c.JPERkgPERCelsius = 4186.0;
			L.LatentHeat Lw = new L.LatentHeat();
			Lw.JPERkg = 3.33E5;
			L.Heat Q = new L.Heat();
			Q.J = m.kg*(c.JPERkgPERCelsius*t.C+Lw.JPERkg);
			L.Work W = new L.Work();
			W.J = Q.J / 5.00;
			L.Power p = new L.Power();
			p.W = 500.0;
			L.Time time = new L.Time();
			time.s = W.J/p.W;
			result+=Convert.ToString(time.s);
		}
	}
}
